<template>
  <div class="heritageRoad">
    <!-- header -->
    <Head />
    <Banner />
    <Nav />
    <!-- /header -->

    <div class="main">
      <div class="middle">
        <!-- 导航栏 -->
        <SideBar></SideBar>
        <!-- 导航栏 -->
        <!-- 获奖情况 -->
        <div class="block">
          <!-- 标题 -->
          <div class="title">
            <h3>获奖情况</h3>
          </div>
          <!-- 内容 -->
          <div class="content">
            <a v-for="(item ,index) in ryzs" :key="index" @click="goAwardsDetail(item.id)">
              <img :src="item.zpurl" alt />
              <span>{{item.title}}</span>
            </a>
          </div>
          <!-- 分页 -->
          <el-pagination
            @size-change="sizeChange"
            @current-change="currentChange"
            :current-page="listQuery.page"
            :page-sizes="[10, 20, 30, 50]"
            :page-size="listQuery.limit"
            layout="total,sizes, prev, pager, next,jumper"
            :total="listQuery.total"
          ></el-pagination>
        </div>
      </div>
    </div>
    <!-- footer -->
    <Footer></Footer>
    <!-- /footer -->
  </div>
</template>

<script>
import Head from "@/components/Head.vue";
import Banner from "@/components/Banner.vue";
import Nav from "@/components/Nav.vue";
import Footer from "@/components/Footer.vue";
import SideBar from "@/components/SideBar.vue";
export default {
  name: "HeritageRoad",
  components: {
    Head,
    Banner,
    Nav,
    Footer,
    SideBar,
  },
  data() {
    return {
      ryzs: [], //获奖情况
      // 页码
      listQuery: {
        total: 1,
        page: 1, //页码
        limit: 10, //每页条数
      },
    };
  },
  created() {
    this.getMenulist();
  },
  methods: {
    //首页接口
    getMenulist() {
      var query = {
        // id: "",
        page: this.listQuery.page,
        limit: this.listQuery.limit,
      };
      this.$axios
        .get("TCM/hjqk", { params: query })
        .then((res) => {
          if (res.status == 200) {
            this.ryzs = res.data.data;
            this.listQuery.total = res.data.count;
            console.log(this.ryzs);
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 跳转到获奖情况详情页
    goAwardsDetail(id) {
      // 点击数加1
      this.addCount(id);
    },
    sizeChange(limit) {
      this.listQuery.limit = limit;
      this.currentChange(1);
    },
    currentChange(page) {
      this.listQuery.page = page;
      this.getMenulist();
    },
    // 增加点击量接口
    addCount(id) {
      let queryData = {
        type: "8",
        id,
      };
      this.$axios
        .post("UpdTCM/addcount", queryData)
        .then((res) => {
          if (res.status == 200) {
            this.$router.push({ path: `/awardsDetail/${id}` });
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
};
</script>

<style lang="less" scoped>
@media screen and (max-width: 1200px) {
  .main {
    margin: 0 !important;
  }
}
.heritageRoad {
  background: url("../assets/image/diwen.jpg") repeat-y;
  // 获奖情况
  .main {
    margin: 0 auto;
    margin: 0 25% 0;
    height: 100%;
    background-color: #ffffff;
    overflow: hidden;
    .middle {
      height: 100%;
      padding: 0 10px 10px;
      background-color: #ffffff;
      box-sizing: border-box;
      margin-top: 20px;
      display: flex;
      justify-content: space-between;
      .block {
        flex: 1;
        margin-left: 20px;
        background-color: #ffffff;
        border: 0.5px solid #ebe4d9;
        border-top: none;
        text-align: center;

        .content {
          padding: 10px 10px 0;
          box-sizing: border-box;
          display: flex;
          justify-content: center;
          flex-direction: row;
          flex-wrap: wrap;
          margin-bottom: 40px;
          a {
            cursor: pointer;
            // width: 190px;
            text-align: center;
            margin: 40px;
            // flex: 0.33;
            img {
              height: 200px;
              display: inline-block;
            }
            span {
              display: block;
              margin-top: 10px;
              color: #07519a;
            }
          }
        }
        .el-pagination {
          margin: 30px 0;
          padding: 0;
          text-align: center;
        }
      }
    }
  }
}
</style>
